/**
 * 获取文件大小
*/

#include <stdio.h>
#include <stdlib.h>

#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc, char **argv)
{
    int fd;

    if (argc <= 1)
    {
        fprintf(stderr, "Usage: %s file_name\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    if ((fd = open(argv[1], O_RDONLY)) < 0)
    {
        perror("Open error");
        exit(EXIT_FAILURE);
    }

    printf("file size = %ld\n", lseek(fd, 0, SEEK_END));

    return 0;
}
